clear
set more off

local titlescore "Occupational"

*Ever Married by Quartile

foreach var in score{

***** 30 yr*****

use $tempdir/panel_trends_30yr_income.dta, clear
keep if race==1

sort year sex
by year sex: egen mean_father_spouse = mean(logocc`var'_father_spouse)

collapse (mean) logocc`var'_father_spouse logocc`var'_father mean_father_spouse, by(qtl_`var'_wgt_full sex year2)
drop if qtl_`var'_wgt_full==.

gen birth_cohort = year2 - 37.5 
gen quartile = qtl_`var'_wgt_full

gen demean_father_spouse = logocc`var'_father_spouse - mean_father_spouse

graph twoway scatter logocc`var'_father_spouse birth_cohort if quartile==1 & sex==2, sort(year2) connect(direct)  lcolor(gs0) lwidth(thick) lpattern(solid) mcolor(gs0) msymbol(circle)  || /*
	*/ scatter logocc`var'_father_spouse birth_cohort if quartile==2 & sex==2, sort(year2) connect(direct)  lcolor(gs3) lwidth(thick) lpattern(dash) mcolor(gs3) msymbol(diamond)  || /*
	*/ scatter logocc`var'_father_spouse birth_cohort if quartile==3 & sex==2, sort(year2) connect(direct)   lcolor(gs6) lwidth(thick) lpattern(shortdash) mcolor(gs6) msymbol(triangle) || /*
	*/ scatter logocc`var'_father_spouse birth_cohort if quartile==4 & sex==2, sort(year2) connect(direct)  lcolor(gs9) lwidth(thick) lpattern(dot) mcolor(gs9) msymbol(square) /*
	*/ legend(label(1 "Quartile 1 (lowest)") label(2 "Q2") label(3 "Q3") label(4 "Q4")) /*
	*/ xtitle("15 year birth cohort") ytitle("Log Father-in-Law Occscore") graphregion(fcolor(white) lcolor(white))

graph export "$outputdir/husb_ses_byqtl.pdf", replace
	
}

*Ever Married by Region

foreach var in score{
***** 30 yr*****

use $tempdir/panel_trends_30yr_income.dta, clear
keep if race==1

sort year 
by year: egen mean_father_spouse = mean(logocc`var'_father_spouse)

collapse (mean) logocc`var'_father_spouse logocc`var'_father mean_father_spouse, by(region_birth_coarse sex year2)

gen birth_cohort = year2 - 37.5 

gen demean_father_spouse = logocc`var'_father_spouse - mean_father_spouse

graph twoway scatter logocc`var'_father_spouse birth_cohort if sex==2 & region_birth_coarse == 1, sort(year2) connect(direct) lcolor(navy) lwidth(thick) mcolor(navy) msymbol(square)  || /*
	*/ scatter logocc`var'_father_spouse birth_cohort if sex==2 & region_birth_coarse == 2, sort(year2) connect(direct) lcolor(dkgreen) lwidth(thick) mcolor(dkgreen) msymbol(diamond) || /*
	*/ scatter logocc`var'_father_spouse birth_cohort if sex==2 & region_birth_coarse == 3, sort(year2) connect(direct) lcolor(maroon) lwidth(thick) mcolor(maroon) msymbol(triangle) /*
	*/ legend(rows(1) label(1 "Northeast") label(2 "Midwest") label(3 "South")) /*
	*/ xtitle("15 year birth cohort") ytitle("Log Father-in-Law Occscore") graphregion(fcolor(white) lcolor(white))

graph export "$outputdir/husb_ses_byreg.pdf", replace

}
